package com.anli.web;

import com.anli.service.LockStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.UUID;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/8  13:58
 * 描述: 用下单锁库存的案例 讲解redis分布式锁
 */

@RestController
public class TestRedisLockController {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate1;


    @Autowired
    private LockStockService lockStockService;

    /**
     * 作者: LCG
     * 日期: 2021/3/8  14:00
     * 描述: 锁库存
     * @Param [map]
     * @Return java.lang.String
     */
    @RequestMapping("lockStock")
    public String test01(){

        String string = UUID.randomUUID().toString();

        System.out.println("========进入锁库存=======");
        lockStockService.stockGoods("100",string,100L,1);

        return null;
    }

    @RequestMapping("lockStock2")
    public String test02(){

        String string = UUID.randomUUID().toString();

        System.out.println("========进入锁库存=======");
        lockStockService.stockGoods2("100",string,100L,1);

        return null;
    }

}
